<?php
/**
 * Blog categorys
 */

$loggedin_user = elgg_get_logged_in_user_entity();
$page_owner = elgg_get_page_owner_entity();
//print_r($page_owner);

if (elgg_instanceof($page_owner, 'user')) {
	//$url_segment = 'blog/category/' . $page_owner->username;
	$url_segment = 'blog/category/all';
} elseif ($vars['page']=='all'||$vars['page']=='category'||$vars['page']=='archive') {
	$url_segment = 'blog/category/all';
} else {
	//$url_segment = 'blog/group/' . $page_owner->getGUID() . '/category';
	//$url_segment = 'blog/category/' . $page_owner->getGUID();
	$url_segment = 'blog/category/all';
}

// This is a limitation of the URL schema.
if (($vars['page']=='all'||$vars['page']=='category'||$vars['page']=='archive')||($page_owner && $vars['page'] != 'friends')) {
	$categories = get_blog_category_array();

	if ($categories) {
		$title = 'Categories';//elgg_echo('blog:categorys');
		$content = '<ul class="blog-categorys">';
		foreach ($categories as $id=>$str) {
			$link = elgg_get_site_url() . $url_segment . '/' . $id;
			$content .= "<li><a href=\"$link\" title=\"$str\">$str</a></li>";
		}
		$content .= '</ul>';

		echo elgg_view_module('aside', $title, $content);
	}
}